package com.test.javafaq_portal.controller;
//下面的注解表示当前类不是一个控制器，而是对控制器功能进行统一的增强


import com.test.javafaq_portal.service.ServiceException;
import com.test.javafaq_portal.vo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class ExceptionControllerAdvice {

    @ExceptionHandler
    public R handlerServiceException(ServiceException e){
        log.error("业务异常:{}" ,e);
        return R.failed(e);
    }

    @ExceptionHandler
    public R handlerException(Exception e){
        log.error("其他异常:{}" ,e);
        return R.failed(e);
    }

}
